package org.skywork.top.core.algorithm.tree;

import org.skywork.top.core.algorithm.support.TreeNode;

import java.util.ArrayList;
import java.util.List;

/**
 * 对称二叉树
 */
public class no_101 {

    /**
     *  给你一个二叉树的根节点 root ， 检查它是否轴对称。
     */
    public boolean isSymmetric(TreeNode root) {
        return root == null || recur(root.left, root.right);
    }
    boolean recur(TreeNode L, TreeNode R) {
        if (L == null && R == null) return true;
        if (L == null || R == null || L.val != R.val) return false;
        return recur(L.left, R.right) && recur(L.right, R.left);
    }
}
